package br.com.comanda.webservice.model;

// Generated 08/05/2012 22:04:45 by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import com.sun.xml.internal.bind.CycleRecoverable;

/**
 * CountItens generated by hbm2java
 */
@XmlRootElement
@Entity
@Table(name = "item", catalog = "comanda")
public class Item implements java.io.Serializable, CycleRecoverable {

	private static final long serialVersionUID = -269240593436311585L;

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Long id;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "product_id", nullable = false)
	private Product product;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "account_id", nullable = false)
	private Account account;

	@Column(name = "quantity_product")
	private Integer quantity;

	@Column(name = "total")
	private Double total;

	public Item() {
	}

	public Item(Long id, Product product, Account account) {
		this.id = id;
		this.product = product;
		this.account = account;
	}

	public Item(int id) {
		this.id = (long) id;
	}

	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Account getAccount() {
		return this.account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getQuantity() {
		return this.quantity;
	}

	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	public Double getTotal() {
		return this.total;
	}

	public void setTotal(Double total) {
		this.total = total;
	}

	public Object onCycleDetected(Context context) {
		Item item = new Item();
		item.setId(this.id);
		return item;
	}

}
